package jsu.bza.work2;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter

public class ApiResponse<T> {
    private T data;
    private String message;
    private String status;
    private String errorCode;
    private long timestamp;
    public ApiResponse( String status,String message, T data, String errorCode) {
        this.status = status;
        this.data = data;
        this.message = message;
        this.errorCode = errorCode;
        this.timestamp = System.currentTimeMillis();
    }
    public static <T> ApiResponse<T> success (String message,T data){
        return new ApiResponse<>("success",message,data,"0");//0代表无错误
    }
    public static <T> ApiResponse<T> error (String message,String errorCode){
        return new ApiResponse<>("error",message,null,errorCode);
    }
}
